#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>


int main(int argc, char const *argv[])
{
   /*
   服务端socket 的建立连接 需要 绑定ip地址和端口， 设置套接字为监听模式，建立监听队列， 然后建立连接*/
   struct sockaddr_in sever_addr;
   int sockfd = socket(AF_INET, SOCK_STREAM, 0);

   bzero(&sever_addr, sizeof(sever_addr));

   sever_addr.sin_family = AF_INET;
   sever_addr.sin_addr.s_addr = inet_addr(argv[1]);
   sever_addr.sin_port = htons(atoi(argv[2]));
   int ret = bind(sockfd, (struct sockaddr *)&sever_addr, sizeof(sever_addr));
   if (ret == -1) {
      perror("bind error");
      exit(EXIT_FAILURE);
   }
    close(sockfd);
    return 0;
}
